package cc.zy.base.businesses.controller;

import cc.zy.base.businesses.entity.*;
import cc.zy.base.businesses.service.IEntranceScoreService;
import cc.zy.base.common.controller.BaseController;
import cc.zy.base.common.entity.FebsResponse;
import cc.zy.base.common.entity.QueryRequest;
import com.baomidou.mybatisplus.core.metadata.IPage;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Controller;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;
import javax.servlet.http.HttpSession;
import java.util.*;

/**
 * 入学成绩模块 Controller
 *
 * @author wangpin
 * @date 2021/02/01
 */
@Slf4j
@Validated
@Controller
@RequiredArgsConstructor
@RequestMapping("entranceScore")
public class EntranceScoreController extends BaseController {
    @Resource
    private IEntranceScoreService iEntranceScoreService;


    /**
     * @param request
     * @param
     * @return
     * @author wangpin
     * 查询列表数据
     * @date 2021/02/01
     */
    @GetMapping("errorLogList")
    @ResponseBody
    public FebsResponse errorLogList(QueryRequest request, HttpSession session) {

        log.debug(String.format(" request = %s", request));
        log.debug(String.format(" 获取错误日志唯一标识 unique = %s", (String) session.getAttribute("unique")));

        IPage<ErrorLog> errorLogs = this.iEntranceScoreService.getErrorLogs(request, session);
        Map<String, Object> dataTable = getDataTable(errorLogs);

        log.debug(String.format(" 返回错误日志信息 unique = %s", dataTable));
        return new FebsResponse().success().data(dataTable);
    }
}
